package org.bookr.engine.model;

import java.util.HashSet;
import java.util.Set;

/**
 * @author Pawel Tomaszewski
 */
public class Category extends AbstractBookrEntity {
    protected String name, description;
    protected Set<Book> books = new HashSet<Book>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Set<Book> getBooks() {
        return books;
    }

    public void setBooks(Set<Book> books) {
        this.books = books;
    }

    public void addBook(Book book) {
        if(!books.contains(book)) {
            books.add(book);
            book.setCategory(this);
        }
    }

    public void removeBook(Book book) {
        if(books.contains(book)) {
            books.remove(book);
            book.setCategory(null);
        }
    }
}
